home *** CD-ROM | disk | FTP | other *** search
- /* =====================
- * PedDispenserString.cc
- * =====================
- */
-
- #include "SiesString.hh"
-
- #include "PedDispenserString.hh"
- #include "PedBuffer.hh"
- #include "PedStreamInputBuffered.hh"
-
- PedDispenserString::PedDispenserString(PedStreamInputBuffered &inStream)
- : mStream(inStream)
- {
- mStream.retain();
- mStream.Flush();
- }
-
- PedDispenserString::~PedDispenserString()
- {
- mStream.release();
- }
-
-
- bool
- PedDispenserString::GetString(SiesString &outString)
- {
- outString.Set("\p");
- long count = mStream.CountAheadThroughChar('\n');
- if (count >= 0) {
- while (count == 0) {
- long size = mStream.SizeOfNextChunk();
- PedBuffer buf(size);
- buf.SetLength(mStream.GetChunk(size, buf.Ptr()));
- outString.Append(buf.Ptr(), buf.Length());
- count = mStream.CountAheadThroughChar('\n');
- }
- if (count > 0) {
- PedBuffer buf(count);
- buf.SetLength(mStream.GetChunk(count, buf.Ptr()) - 1);
- outString.Append(buf.Ptr(), buf.Length());
- count = mStream.CountAheadThroughChar('\n');
- } else {
- // trailing newline is missing
- }
- } else {
- return false;
- }
- return true;
- }
-
- #if 0
- bool
- PedDispenserString::GetString(SiesString &outString)
- {
- outString.Set("\p");
- long countCR, countLF, count, min, max;
- countCR = mStream.CountAheadThroughChar(13);
- countLF = mStream.CountAheadThroughChar(10);
- min = (countCR < countLF) ? countCR : countLF;
- max = (countCR > countLF) ? countCR : countLF;
- count = (min == 0) ? max : min;
- if (count >= 0) {
- while (count == 0) {
- long size = mStream.SizeOfNextChunk();
- PedBuffer buf(size);
- buf.SetLength(mStream.GetChunk(size, buf.Ptr()));
- outString.Append(buf.Ptr(), buf.Length());
- count = mStream.CountAheadThroughChar(13);
- }
- if (count > 0) {
- PedBuffer buf(count);
- buf.SetLength(mStream.GetChunk(count, buf.Ptr()) - 1);
- outString.Append(buf.Ptr(), buf.Length());
- count = mStream.CountAheadThroughChar(13);
- } else {
- // trailing newline is missing
- }
- } else {
- return false;
- }
- return true;
- }
- #endif
-